<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="probiz" tagdir="/WEB-INF/tags/probiz"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<c:if test="${not empty msgTemplate.msgTemplateId}">
	<!-- 针对新增时可以测试发送消息，发送后，原heading不变 -->
	<c:set var="entityName" value="${msgTemplate.msgTemplateId}"></c:set>
</c:if>
<probiz:pageHeading entityName="${entityName}" entityHeadingKey="msgTemplate.formTabTitle" />
<content tag="buttons">
<probiz:iconBtn btnType="save" onclick="return fnDoSave(this,'entityName');" />
<probiz:iconBtn btnType="back" onclick="return fnDoCancelForm(this);" />
<div class="line"></div>
</content>
<c:choose>
	<c:when test="${msgTemplate.type == 0}">
		<c:set var="msgType" value="邮件模板编辑"></c:set>
	</c:when>
	<c:when test="${msgTemplate.type == 1}">
		<c:set var="msgType" value="站内信模板编辑"></c:set>
	</c:when>
	<c:when test="${msgTemplate.type == 2}">
		<c:set var="msgType" value="手机短信模板编辑"></c:set>
	</c:when>
</c:choose>
<div class="top clearfix">
	<ul class="tab">
		<li class="curr">
			<span>${msgTemplate.templateName}${msgType }
			</span>
		</li>
	</ul>
</div>
<div class="modify">
	<form:form cssClass="mainForm" method="post" id="msgTemplate" commandName="msgTemplate" 
		action="${ctxPath}/system/msgTemplate.html" onsubmit="return fnOnSubmit(this);">
		<form:hidden path="version" />
		<input type="hidden" name="msgTemplateId" value="${msgTemplate.msgTemplateId}" />
		<input type="hidden" name="templateCode" value="${msgTemplate.templateCode}" />
		<input type="hidden" name="templateName" value="${msgTemplate.templateName}" />
		<input type="hidden" name="templateItem" value="${msgTemplate.templateItem}" />
		<input type="hidden" name="type" value="${msgTemplate.type}" />
		<input type="hidden" name="status" value="${msgTemplate.status}" />
		<input type="hidden" name="isStoreAdmin" value="${msgTemplate.isStoreAdmin}" />
		<input type="hidden" name="labelsVariable" value='${msgTemplate.labelsVariable}' />
		<input type="hidden" name="title" value="${msgTemplate.title}" />
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table" >
			<tr>
				<th class="label_width_1">
					<StoreAdmin:label key="msgTemplateDetail.variable.label" />
				</th>
				<td>
					<table border="1" cellspacing="2" style="border: 1px solid;width:900px;table-layout:auto">
						<c:forEach items="${labelsVariablesList}" var="trList">
							<tr style="border: 1px solid">
								<c:forEach items="${trList}" var="tdList">
									<th style="border: 1px solid;background-color: #E6EFF5;"><div style=" width:105px;"><b>${ tdList[0]}</b></div></th>
									<td style="border: 1px solid; background-color: #F5F5FB;"><div style=" width:280px; word-wrap:break-word;">${ tdList[1]}</div></td>
								</c:forEach>
							</tr>
						</c:forEach>
					</table>
				</td>
			</tr>
			<%---
			<c:if test="${msgTemplate.type == 0}">
				<tr>
					<th>
						<StoreAdmin:label key="msgTemplate.title.0" />
					</th>
					<td>
						<spring:bind path="msgTemplate.title">
							<input class="inputtxt" type="text" name="${status.expression}" id="${status.expression}"
								value="${status.value}" style="width: 350px" maxlength="256" />
							<span class="fieldError">${status.errorMessage}</span>
						</spring:bind>
					</td>
				</tr>
			</c:if>
			--%>
			<tr>
				<th>
					<StoreAdmin:label key="msgTemplate.content" />
				</th>
				<td>
					<c:choose>
						<c:when test="${msgTemplate.type == 0}">
							<textarea id="content_html" name="content" cols="160" rows="25" class="textareatxt">${msgTemplate.content}</textarea>
							<probiz:plugin_htmlEditor textareaIds="content_html"/>
							<probiz:plugin_tip id="fullDescription_tip"><fmt:message key="description.tip" /></probiz:plugin_tip>
						</c:when>
						<c:otherwise>
							<textarea id="content" name="content" cols="160" rows="25" class="textareatxt">${msgTemplate.content}</textarea>
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
	</form:form>
</div>
<v:javascript formName="msgTemplate" staticJavascript="false" />
<script type="text/javascript">
	$j(document).ready(function(){
		applyValidate($('content_html'),"maxlength=65535");
	});
	function fnOnSubmit(oForm){
		if(${msgTemplate.type}==0){
			KE.util.setData('content_html');
		}else{
			//KE.util.setData('content');
		}
		return validateMsgTemplate(oForm);
	}
	
</script>